import './App.css'
import {useSelector,useDispatch} from 'react-redux'
import { decrement } from './store/modules/counter';


function App() {
  const {count,sum,price} = useSelector((state)=>state.count)
  const dispatch = useDispatch()
  return (
    <div>
      <h2>react/redux-toolkit的·基本使用</h2>
      <p>当前数量:
        <button onClick={()=>dispatch(decrement())}>-</button>
        {count}
        <button onClick={()=>dispatch(decrement(3))}>+</button>
        <button onClick={()=>dispatch(decrement(4))}>+++</button>
      </p>
      <p>
        商品单价:{price}
      </p>
      <p>
        总价:{count * price} <span>元</span>
        总价:{sum}<span>元</span>
      </p>
    </div>
  );
}

export default App;

